package jdk7.others;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;

public class TestFiles {
	public void manipulateFiles() throws IOException {
		Path newFile = Files.createFile(Paths.get("new.txt").toAbsolutePath());
		System.err.println(newFile);
		List<String> content = new ArrayList<String>();
		content.add("Hello");
		content.add("World");
		Files.write(newFile, content, Charset.forName("UTF-8"));
		Files.size(newFile);
		// byte[] bytes = Files.readAllBytes(newFile);
		ByteArrayOutputStream output = new ByteArrayOutputStream();
		Files.copy(newFile, output);
		Files.delete(newFile);
	}

	/**
	 * @param args the command line arguments
	 */
	public static void main(String[] args) throws IOException {
		TestFiles fu = new TestFiles();
		fu.manipulateFiles();
	}
}
